package com.lzq.leetcode.hoot100;

public class s11 {
    public int maxArea(int[] height) {
        int l = 0;
        int r = height.length-1;
        int max = 0;
        while (l < r) {
            int cap = Math.min(height[l], height[r]) * (r-l);
            max = Math.max(max, cap);
            if (height[l]  < height[r]) {
                int cur = height[l];
                while (l < r && height[l] <= cur)   l++;
            } else {
                int cur = height[r];
                while (l < r && height[r] <= cur)   r--;
            }
        }
        return max;
    }
}
